Image
The *image command is used to add images into the game. Usage Images can be added wherever you want. The simple version is: *image wolf.png You found a wolf! This will display the wolf.png image in your mygame game folder (..\web\mygame); if you do not have a wolf.png image, the image will not display and there will be no errors. You can, for organizational purposes, create an images folder inside mygame to store your images. If you do this, you need to tell the command where to find your image: *image images/wolf.png Will display the wolf.png file stored in your images folder in the mygame folder (..\web\mygame\images). Format ChoiceScript supports most image formats, the most common of which are: * PNG - this format is the best choice for quality due to the lossless compression it uses. It also supports transparency. * JPG - images in this format are compressed to a much smaller file size, and as a result, loose a bit of their quality. JPG images do not support transparency. * BMP - images in this format are uncompressed, and therefore preserve the image's quality. Because they aren't compressed, they can be very large however. * GIF - this format is similar to PNG as it supports transparency, but lacks the quality of a PNG file. Gif images can, however, be animated. ;Visual format comparison: wolf.png|Wolf image in the PNG format with a transparent background. The quality is preserved very well. wolf.jpg|Wolf image in the JPG format. It does not support transparency (white background), and looses some quality. wolf.gif|Wolf image in the GIF format with a transparent background. Notice the poor quality which is very apparent near the edges. wolf-animated.gif|Image of an animated wolf in the GIF format with a transparent background. Size The *image command takes care of the size of the image: images will automatically be sized down if the width of the image is larger than the width of the device used to play the game. Images will never be sized up because that would cause the image to be stretched. It is best to insert a large, high-quality image that will be downsized. Alignment But, what if you want the image to "stick" to a side of the screen? Here's what you do: *image wolf.png left or *image wolf.png right or *image wolf.png center These "left" and "right" will stick your image to a side of the screen, and the "center" will make your image stick in the center of the screen (if you do not, however, write any word, the image will stick to the center by default). Alternate text It is good practice to add alternate descriptive text associated with the image, which will be shown in case the image cannot be displayed for some reason. This is also very useful for visually impaired players who use a screen reader. *image wolf.png center A lone, mangy wolf howling at the moonlight. The text "A lone, mangy wolf howling at the moonlight." is not a caption and will not be displayed unless the image is unavailable. Note: the alignment parameter must be set between the image source (wolf.png) and the alt text (A lone, mangy wolf howling at the moonlight.), otherwise it will throw an error. "None" is an acceptable alignment parameter if you do not wish to specify "left", "right" or "center". Category:Commands